﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DigitalAnts.App_Code.BAL.Components;
using DigitalAnts.App_Code.BAL.Entities;
using System.Data;
using BAL.Entities;

namespace DigitalAnts.Admin
{
    public partial class Feedback : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Login() == false)
            {
                Response.Redirect("~/Admin/EmployeeLogin.aspx");
            }
            else
            {
                if (!IsPostBack)
                {
                    showFeedback();
                    readFeedback();
                }
            }
        }

        public bool Login()
        {
            clsEmployee obj = new clsEmployee();
            obj.UserName = Session["AdminUser"].ToString();
            obj.Role = Session["Role"].ToString();

            return clsEmployeeLoginBAL.queryEmployeeLogin(obj);
        }

        public void showFeedback()
        {
            gvfeedback.DataSource = clsFeedbackBAL.doFeedbackSelectList();
            gvfeedback.DataBind();
        }

        public void readFeedback()
        {
            if (Request["FeedbackID"] != null)
            {
                clsFeedback obj = new clsFeedback();
                obj.FeedbackID = Convert.ToInt32(Request["FeedbackID"].ToString());

                DataTable dt = clsFeedbackBAL.doFeedbackSelectListByID(obj);
                txtdetail.Text = dt.Rows[0]["colDetail"].ToString();
                txtcontent.Text = dt.Rows[0]["colContent"].ToString();
                txtemail.Text = dt.Rows[0]["colEmail"].ToString();
            }
        }
    }
}